﻿Public Class DmLoaiTien

    ' Private Sub FormLoaiTien_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles Me.KeyDown
    Protected Overrides Function ProcessCmdKey(ByRef msg As System.Windows.Forms.Message, ByVal keyData As System.Windows.Forms.Keys) As Boolean
        ' If e.KeyCode = (e.Control And Keys.N) Then
        If keyData = (Keys.Control Or Keys.N) Then
            Return Me.DmloaitienIUltraGrid.getTaoMoi()
        End If
        If keyData = (Keys.Control Or Keys.S) Then
            Me.DmloaitienIUltraGrid.getLuu()
            Return True
        End If
        If keyData = (Keys.Control Or Keys.D) Then
            Return Me.DmloaitienIUltraGrid.getXoa()
        End If
        If keyData = (Keys.Control Or Keys.R) Then
            Return Me.DmloaitienIUltraGrid.getRefresh()
        End If
        If keyData = (Keys.Control Or Keys.P) Then
            Return getIn()

        End If
        If keyData = (Keys.Control Or Keys.Q) Then
           Return getThoat()
        End If
        Return MyBase.ProcessCmdKey(msg, keyData)
    End Function


    Private Sub DmLoaiTien_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Me.Cursor = Cursors.WaitCursor
        'TODO: This line of code loads data into the 'ErpharmaDataSet.dmloaitien' table. You can move, or remove it, as needed.
        Me.DmloaitienTableAdapter.Fill(Me.ErpharmaDataSet.dmloaitien)
        Me.DmtinhtrangTableAdapter.Fill(Me.ErpharmaDataSet.dmtinhtrang)

        Me.DmloaitienIUltraGrid.setDoiTuongXuLyDuLieu(Me.ErpharmaDataSet.dmloaitien, Me.DmloaitienBindingSource, Me.DmloaitienTableAdapter, Me.ErpharmaDataSet)
        Me.DmloaitienIUltraGrid.setGiaoDienVua()
        Me.DmloaitienIUltraGrid.setTimKiemTrenCotUltraGrid()
        Me.DmloaitienIUltraGrid.setChoPhepMenuStrip_In()
        Me.DmloaitienIUltraGrid.setThemIUltraDropDown(Me.DmtinhtrangIUltraDropDown, Me.ErpharmaDataSet.dmtinhtrang)
        Me.DmtinhtrangIUltraDropDown.setGiaoDien_An_ColumnHeader()
        'set giao diện của iultradropdown
        Me.Cursor = Cursors.Default

    End Sub

    Private Sub btnTaoMoi_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnTaoMoi.Click
        Me.DmloaitienIUltraGrid.getTaoMoi()

    End Sub

    Private Sub btnLuu_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnLuu.Click
        Me.DmloaitienIUltraGrid.getLuu()

    End Sub

    Private Sub btnXoa_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnXoa.Click
        Me.DmloaitienIUltraGrid.getXoa()

    End Sub

    Private Sub btnLamTuoi_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnLamTuoi.Click
        Me.DmloaitienIUltraGrid.getRefresh()

    End Sub
    Private Function getIn() As Boolean
        Try
            Dim rp As DmLoaiTien_Report = New DmLoaiTien_Report
            rp.setDt(Me.DmloaitienIUltraGrid.getDatatableTuIUltraGrid("dmloaitien"))
            rp.Show()
            Me.DmloaitienIUltraGrid.DataSource = Me.ErpharmaDataSet.dmloaitien
        Catch ex As Exception
            ' Return False
            MsgBox("Xảy ra lỗi :" & ex.Message, MsgBoxStyle.Information, "Thông báo")
        End Try
        Return True
    End Function
    Private Sub btnIn_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnIn.Click
        getIn()
    End Sub
    Private Function getThoat() As Boolean
        Try
            Me.Dispose()
            Me.Close()
        Catch ex As Exception
            Return False
        End Try
        Return True
    End Function
    Private Sub btnThoat_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnThoat.Click
        getThoat()
    End Sub
End Class